/***************************************************************************
 创建者: hualei
 开始时间: 2018-10-20
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2018-10-15 类的具体实现代码编写

 ***************************************************************************
 *  MUSIC 音乐指令具体实现
 ***************************************************************************/
#ifndef MUSICINSTRUCTIONLOGIC_H
#define MUSICINSTRUCTIONLOGIC_H

#include "instructionEnum.h"
#include "GeneralDefine.h"
#include <QObject>



class ProgramSet;
class ProgramEngine;
class MusicInstruction;

class MusicInstructionLogic : public QObject
{
public:
    MusicInstructionLogic(int robotIdIn, ProgramSet *programSetIn, ProgramEngine *programEngineIn);

    E_PROGRAM_LOOP_RESULT startMusic(int programNumIn, MusicInstruction instructionIn);

    int playMusic(QString musicNameIn, int musicPlayTimes, int musicVolume);

    void stopMusic();
    int playSystemMusic(QString nameIn, int musicPlayTimes);
    int playBarriorMusic(double barrierRatioIn);//播放壁障音乐
    int playErrorMusic();//播放报警音乐
    int restoreNormalMusic();//恢复正常音乐

private:
    int conversionVolume(int volumeIn);

private:

    /**
     * @brief addMsg
     * @param messageLevel
     * @param componentName
     * @param messageType
     * @param messageCode
     * @param robotId
     * @param parameter1
     * @param parameter2
     * @param parameter3
     * @param parameter4
     * @param message
     */
    void addMsg( int messageLevel,
                 std::string componentName,
                 std::string messageType,
                 int messageCode,
                 int robotId,
                 int parameter1 = 0,
                 int parameter2 = 0,
                 int parameter3 = 0,
                 int parameter4 = 0,
                 QString message= "");

private:

    ProgramEngine *programEngine;

    ProgramSet *programSet;

    int robotId;

    QString currentRuningMusicCommand;//循环播放的音乐命令寄存

    bool isMusicPlaying;//是否正在播放音乐
};

#endif // MUSICINSTRUCTIONLOGIC_H
